package com.gz.EuchreU.Controls;

import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.input.touch.TouchEvent;

import android.util.Log;

import com.badlogic.gdx.math.Vector2;
import com.gz.EuchreU.Contants.GameState;
import com.gz.EuchreU.Contants.UI;
import com.gz.EuchreU.Helpers.Textures;
import com.gz.EuchreU.Sprite.ButtonSprite;

public class OrderUpMenu extends MovingMenuEntity{

	public OrderUpMenu(float pOnScreenX, float pOnScreenY, float pWidth, Scene pScene) {
		super(pOnScreenX, pOnScreenY, pWidth, false);

		//mOnScreenLocation = new Vector2(10, UI.getHeight()/2);
		
		final ButtonSprite btnPickUp = new ButtonSprite(pOnScreenX + 10,pOnScreenY + 10,pWidth/4,Textures.PICK_UP_TEXTURE) {
			
			@Override
			public boolean onAreaTouched(TouchEvent pSceneTouchEvent,float pTouchAreaLocalX,float pTouchAreaLocalY){
				if(pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP){
					if(mActive){
						log("Pickup button pressed");
						
						
						//TODO: User alone
						GameState.PickUp(false);
					}
					else{
						log("Pickup pressed while inactive...");
					}
				}
				return true;
			}
		};
		
		final ButtonSprite btnPass = new ButtonSprite(pOnScreenX + pWidth/2,pOnScreenY + 10,pWidth/4,Textures.PASS_TEXTURE) {
			
			@Override
			public boolean onAreaTouched(TouchEvent pSceneTouchEvent,float pTouchAreaLocalX,float pTouchAreaLocalY){
				if(pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP){
					if(mActive){
						log("pass button pressed");
						GameState.Pass();
					}
					else{
						log("pass button pressed while inactive...");
					}
				}
				return true;
			}
		};
		
		attachChild(btnPickUp);
		attachChild(btnPass);
		
		pScene.registerTouchArea(btnPass);
		pScene.registerTouchArea(btnPickUp);
		
	}

	private void log(String msg){
		Log.d("OrderUpMenu",msg);
	}
	
}
